<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>

<html>
	<head>
		<title>系统类别树管理</title>
	</head>
	<script type="text/javascript">
		$(function(){
		    $('#tt').treegrid({  
		    	fitColumns:true,
				url: '<%=contextPath %>/springMVC/group/getSystemType',
				animate:true,
				collapsible:true,
				idField: 'id',
				treeField: 'name',
		        columns:[[  
		            {field:'id',hidden:true},  
		            {field:'_parentId',hidden:true},  
		            {field:'parent_name',hidden:true},  
		            {field:'type',hidden:true},
		            {field:'tree_code',hidden:true},
		            {field:'name',title:'名称',width:200},  
		            {field:'sort',title:'排序号',width:100},  
		            {field:'operation',title:'操作',width:100,formatter: function(value,row,index){
		            	var id = row.id;
		            	var name = row.name;
		            	var tree_code = row.tree_code;
		            	var type = row.type;
		            	return "<input type='button'  title='添加子节点' style='border:0px #ff0000 solid;cursor:pointer' class='icon-add' onClick='addNode(\""+id+"\",\""+name+"\",\""+tree_code+"\",\""+type+"\")'/>"
		            		  +"&nbsp;<input type='button' title='编辑' style='border:0px #ff0000 solid;cursor:pointer' class='icon-edit' onClick='editNode(\""+id+"\")'/>"
		            		  +"&nbsp;<input type='button' title='删除' style='border:0px #ff0000 solid;cursor:pointer' class='icon-remove' onClick='deleteNode(\""+id+"\")'/>";
		            }}
		        ]]
		    });  
		});
		function rtCallBack(){
			$('#tt').treegrid('reload');
		}
		function addNode(parent_id,parent_name,parent_tree_code,parent_type){
			var param = "parent_type="+parent_type+"&parent_id="+parent_id+"&parent_tree_code="+parent_tree_code+"&parent_name="+encodeURIComponent(parent_name)+"&callback=rtCallBack";
			openDialogResize("<%=contextPath %>/springViews/system/addOrEditSystemType.jsp?"+param,800, 600);
		}
		function editNode(id){
			openDialogResize("<%=contextPath %>/springViews/system/addOrEditSystemType.jsp?id="+id+"&callback=rtCallBack",800, 600);
		}
		function deleteNode(id){
			$.messager.confirm('确认','您确认删除该记录信息？',function(msg){
				if(msg){
					$.ajax({
						type:'POST',
						url:"<%=contextPath %>/springMVC/group/deleteSystemType?id="+id,
						success:function(rtJson){
							if(rtJson.rtState == '0'){
								rtCallBack();
							}
							else{
								warningInfo(rtJson.rtMsrg);
							}
						}
					});
				}
			});
		}
	</script>
	<body>
	<div style="padding-bottom: 20px">
		<table id="tt" title="系统类别树管理" class="easyui-treegrid"></table>
				</div>
	</body>
</html>
